
import java.lang.reflect.Method;
import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author TQNINH
 */
public class Customer {
    public int cCode;
    public String cName;
    public int cAge;
    
    public Customer() {
        
    }
    
    public Customer(int c, String n, int a) {
        cCode = c;
        cName = n;
        cAge = a;
    }
    
    public void menu() {
        System.out.println("CUSTOMER MANAGEMENT PROGRAM\n");
        System.out.println("1- Add new Customer (Name of file accept from user)");
        System.out.println("2- DisplayAll (Display all Customers in the file created in question 1");
        System.out.println("3- Display the content of created file in the application Notedpad");
        System.out.println("4- Display information of methoeds of class Customer");
        System.out.println("5- Exit (Quit the application)");
    }
    
    public void addCustomer(String fileName, Customer cus) {
        
    }
    
    public void displayAll(String filename) {
        
    }
    
    public void displayInNotepad(String filename) {
        
    }
    
    public void displayMethods(Customer cus) {
        // Step-1
        Class clsCustomer = cus.getClass();
        // Step-2
        Method[] theMethods = clsCustomer.getMethods();
        // Step-3
        for (int i = 0; i < theMethods.length; i++) {
            System.out.println("\n");
            // Step-3.1
            String methodString = theMethods[i].getName();
            System.out.println("Method Name: " + methodString);
            // Step-3.2
            String returnString = theMethods[i].getReturnType().getName();
            System.out.println("Return Type: " + returnString);
            // Step-3.3
            Class[] parameterTypes = theMethods[i].getParameterTypes();
            System.out.print("Parameter Types: ");
            // Step-3.4
            for (int k = 0; k < parameterTypes.length; k++) {
                String parameterString = parameterTypes[k].getName();
                System.out.print((k + 1) + ". " + parameterString + " ");
            }
        }
    }
    
    public static void main(String[] args) {
        Customer obj = new Customer();
        String fileName = "";
        int choose = 0;
        do {
            obj.menu();
            do {
                System.out.print("\nChoose: ");
                Scanner input = new Scanner(System.in);
                input.useDelimiter("\n");
                try {
                    choose = input.nextInt();
                } catch(NumberFormatException e) {
                    System.out.println("Please enter an integer 1-5.");
                }
                if(choose < 1 || choose > 5) {
                    System.out.println("Please enter an integer 1-5.");
                }
            } while(choose < 1 || choose > 5);
            switch(choose) {
                case 1:
                    obj.addCustomer(fileName, obj);
                    break;
                case 2:
                    obj.displayAll(fileName);
                    break;
                case 3:
                    obj.displayInNotepad(fileName);
                    break;
                case 4:
                    obj.displayMethods(obj);
                    break;
                case 5:
                    System.out.println("Good bye see you next time!");
                    System.exit(0);
            }
        } while(choose != 5);
    }
}
